#!/usr/bin/env bash
#ps -ef|grep docker || 
wget -qO- https://get.docker.com/ | sh &&
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && 
sudo chmod +x /usr/local/bin/docker-compose &&
ls /home/wordpress || mkdir -p /home/wordpress && 
echo "version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - '80:80'
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:" >> /home/wordpress/docker-compose.yml &&
cd /home/wordpress && 
sudo service docker start &&
docker-compose up -d